<template>
  <div id="app">  
    <div id="nav">
   
  <el-menu router :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
  <el-menu-item index="/home">首页</el-menu-item>
  <el-menu-item index="/findcar">寻找车位</el-menu-item>
  <el-menu-item index="/order">发布车位</el-menu-item>
  <el-menu-item index="/Rentout">添加车位</el-menu-item>
  <div>欢迎您！{{loginName}}</div>
  <el-menu-item index="/person" style=' margin-left: 1200px'>个人中心</el-menu-item>
  <el-menu-item index="/comment">评论中心</el-menu-item>
</el-menu>

<div class="line"></div>
    </div>
   <router-view/>
 
  </div>
</template>

<script>
  export default {
    data() {
      return {
        activeIndex: '/home',
        loginName:'',
      }
    },

     methods: {
      handleSelect(key, keyPath) {
        console.log(key, keyPath);
      },
      findUserName(){
        this.$http.get("/findBalance",{
          params:{
            userId:localStorage.getItem("loginUser"),
          }
        })
        .then(response => {
         this. loginName=response.data.data.username
        })
      }
    },
    mounted(){
      this.$router.push('/home');
      this.findUserName();
    }
  }
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  
}

#nav {
  padding: 30px;
}

#nav a {
  font-weight: bold;
  color: #2c3e50;
}

#nav a.router-link-exact-active {
  color: #42b983;
}
</style>
